Novel coronavirus (Covid-19) is declared a pandemic by WHO. Almost all country is suffering and most of them are in a lockdown situation. Hundreds of thousands are infected and thousands are dead and this number is increasing exponentially. Only emergency services like hospitals, electricity, water supply are in operation with possible precautions. People are not allowed to step out of their homes.
Some websites like Worldometers, Corona Virus Esri API show real-time corona cases, the number of recovers, deaths, etc. Based on the data displayed over this website we will show you how to display data and manipulate it according to your requirement. In this tutorial, we display Covid-19 world and SAARC data (total cases, death, and recovery).
Note*: SAARC represents for “South Asian Association for Regional Cooperation” as an inter-governmental organization and its member countries are Afghanistan, Bangladesh, Bhutan, India, the Maldives, Nepal, Pakistan, and Sri Lanka.
Figure: Author Prototype of ESP32 Based Real-Time Corona Case Counter
Circuit Diagram ESP32 Based Real-Time Corona Case Counter
In the project “ESP32 Based Real-Time Corona Case Counter,” we will build a DIY corona real-time counter for the world and SAARC. It shows different parameters like total no of cases, death, and recovery. This DIY project is simple and required only two components i.e. ESP32 and I2C LCD. For this project an RGB I2C LCD by seeedstudio, the circuit is shown in figure 1. ESP32 is used here to fetch data from the web and display it over RGB LCD. Two pins of LCD, SCL, and SDA are connected to SCL and SDA pin of ESP32 where the power supply is connected to power rails (+5V and GND) as shown in the circuit diagram.
Note: The I2C LCD module we had used in this project requires a 5V power supply and ESP32 does not have a 5V supply pin thus we had used an external 5V power supply.
Getting API Ready for Real-Time Corona Case Counter
Getting JSON code for SAARC
Step 1: Go to website “coronavirus-disasterresponse”
Step 2: Select the parameter you need like specific country, confirmed, recover, death, etc.
Figure 2: Selecting Parameter for Corona Virus
Note: In this article, we are showing confirmed cases, death, and recovery of SAARC country.
Step 3: Make all the output and input parameters either OFF or False.
Figure 3: Selecting Input and Output Parameter for JSON Code
Step 4: Click on either “Try it out” or on the link on the right side “Query URL”. There you will get JSON data.
Figure 4: JSON Code for Corona Case
Step 5: We had manipulated the URL to get data of a specific country. In URL change the country name you want to display the data.
1 |
https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27Nepal%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths |
Note: This URL is for the country Nepal.
Step 5: Now we have to phrase the JSON data according to our requirement for that go to the link ArduinoJson Assistant and paste the JSON code in input.
Figure 5: Input Code for JSON Phrasing
Step 6: Copy the code from the phrasing program section as per your requirement, here we are displaying total cases, death, and recovery of SAARC.
Figure 6: Phrasing Program for JSON Code
Step 7: Do the same process for the new country you wish to display on your display.
Getting code for World Data
Step 1: Go to the website “Worldometers”
Step 2: Scroll down and then right-click on the world total case cell, go to inspect element.
Figure 7: Inspect Element of World Case
Step 3: Copy the XPath of World Total Case (You can copy XPath either by clicking three-dot (…) or by right-click).
Figure 8: XPath for World Case
Step 4: Now open the ThingSpeek website and then go to Apps>>ThingHTTP
Figure 9: ThingSpeek Page
Step 5: Now click on NewThingHTTP. (Note: For testing, we had created a few HTTP).
Figure 10: Dashboard for HTTP
Step 6: In Name field, add the name (say World Case); in URL field add the ERL of WorldoMeter “https://www.worldometers.info/coronavirus/”; in Phrasing Field add the XPath of world case that you had copied from worldometer and finally save the data by clicking Save ThingHTTP.
Figure 11: HTTP Setup for ThingSpeak
Step 7: Note down the API key, you have to use this URL and key in software code.
Figure 12: API Key for HTTP Code
Software Code for ESP32 Based Real-Time Corona Case Counter:
Software code is written in Arduino programming language (C/C++) and compiled using Arduino IDE. You have to edit some code before using it like, URL code, SSID and password, etc.
Note: Before using code you have to update the Arduino JSON library to version 6.15.0.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
#include <HTTPClient.h> #include <WiFi.h> #include <ArduinoJson.h> #include "rgb_lcd.h" rgb_lcd lcd; const char* ssid = "HUAWEI nova 2i"; // WiFi user anme const char* pass = "password"; //WiFi Password const char* host = "api.thingspeak.com"; //We read the data from this host const int httpPortRead = 80; // HTTP post definition //URL we need const char* url1 = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27Afghanistan%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths"; const char* url2 = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27Bangladesh%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths"; const char* url3 = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27Bhutan%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths"; const char* url4 = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27India%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths"; const char* url5 = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27Maldives%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths"; const char* url6 = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27Nepal%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths"; const char* url7 = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27Pakistan%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths"; const char* url8 = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Country_Region=%27Sri%20Lanka%27)&returnGeometry=false&outFields=Country_Region,Confirmed,Recovered,Deaths"; const char* url9 = "/apps/thinghttp/send_request?api_key=Z7ZNS4QDUR554RVV"; //Those URLs are mine but I kept them so you can replace the key only const char* url10 = "/apps/thinghttp/send_request?api_key=MHT7SYQLFLAACP86"; const char* url11 = "/apps/thinghttp/send_request?api_key=YPV7MTZZYD9G13PT"; int To_remove; //There are some irrelevant data on the string and here's how I keep the index of those characters String Cases,Death,Recover,Data_Raw; //Here I keep the numbers that I got void setup() { Serial.begin(115200); lcd.begin(16, 2); Serial.println("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); // print ... till not connected } Serial.println("WiFi connected"); } void loop() { HTTPClient https; String data; Afganistan(); Bangladesh(); Bhutan(); India(); Maldives(); Nepal(); Pakistan(); Srilanka(); World(); } void World() { WiFiClient client; //Create a WiFi client and http client HTTPClient http; if( http.begin(host,httpPortRead,url9)) //Connect to the host and the url { int httpCode = http.GET(); //Check feedback if there's a response if (httpCode > 0) { if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) { Data_Raw = http.getString(); //Here we store the raw data string To_remove = Data_Raw.indexOf(">"); Data_Raw.remove(0,To_remove+1); To_remove = Data_Raw.indexOf("<"); Data_Raw.remove(To_remove,Data_Raw.length()); Cases=Data_Raw; } } else { Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } http.end(); } else //If we can't connect to the HTTP { Serial.printf("[HTTP} Unable to connect\n"); } if( http.begin(host,httpPortRead,url10)) { int httpCode = http.GET(); if (httpCode > 0) { if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) { Data_Raw = http.getString(); To_remove = Data_Raw.indexOf(">"); Data_Raw.remove(0,To_remove+1); To_remove = Data_Raw.indexOf("<"); Data_Raw.remove(To_remove,Data_Raw.length()); Death=Data_Raw; } } else { Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } http.end(); } else { Serial.printf("[HTTP} Unable to connect\n"); } if( http.begin(host,httpPortRead,url11)) { int httpCode = http.GET(); if (httpCode > 0) { if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) { Data_Raw = http.getString(); To_remove = Data_Raw.indexOf(">"); Data_Raw.remove(0,To_remove+1); To_remove = Data_Raw.indexOf("<"); Data_Raw.remove(To_remove,Data_Raw.length()); Recover=Data_Raw; } } else { Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } http.end(); } else { Serial.printf("[HTTP} Unable to connect\n"); } Serial.println("World"); Serial.println(Cases); Serial.println(Recover); Serial.println(Death); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print("___World Data___"); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(6, 1); lcd.print(Cases); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print("___World Data___"); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(7, 1); lcd.print(Death); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print("___World Data___"); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(9, 1); lcd.print(Recover); delay(2000); while (WiFi.status() != WL_CONNECTED) //In case the Wifi connexion is lost { WiFi.disconnect(); delay(1000); WiFi.begin(ssid, pass); Serial.println("Reconnecting to WiFi.."); delay(10000); } lcd.clear(); } void Afganistan() { HTTPClient https; String data; https.begin(url1); int httpCode = https.GET(); if (httpCode > 0) { //Check for the returning code String payload = https.getString(); char charBuf[500]; payload.toCharArray(charBuf, 500); const size_t capacity = JSON_ARRAY_SIZE(4) + JSON_ARRAY_SIZE(7) + 7*JSON_OBJECT_SIZE(1) + 2*JSON_OBJECT_SIZE(2) + 7*JSON_OBJECT_SIZE(4) + 3*JSON_OBJECT_SIZE(6) + 2*JSON_OBJECT_SIZE(7) + 1130; DynamicJsonDocument doc(capacity); deserializeJson(doc, payload); JsonArray fields = doc["fields"]; JsonObject features_0_attributes = doc["features"][0]["attributes"]; const char* features_0_attributes_Country_Region = features_0_attributes["Country_Region"]; // "Afghanistan" int features_0_attributes_Confirmed = features_0_attributes["Confirmed"]; // 84 int features_0_attributes_Recovered = features_0_attributes["Recovered"]; // 2 int features_0_attributes_Deaths = features_0_attributes["Deaths"]; // 2 Serial.println(features_0_attributes_Country_Region); Serial.println(features_0_attributes_Confirmed); Serial.println(features_0_attributes_Recovered); Serial.println(features_0_attributes_Deaths); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Confirmed); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Deaths); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Recovered); delay(2000); } else { Serial.println("Error on HTTP request"); } https.end(); return; } void Bangladesh() { HTTPClient https; String data; https.begin(url2); int httpCode = https.GET(); if (httpCode > 0) { //Check for the returning code String payload = https.getString(); char charBuf[500]; payload.toCharArray(charBuf, 500); //Serial.println(payload); const size_t capacity = JSON_ARRAY_SIZE(4) + JSON_ARRAY_SIZE(7) + 7*JSON_OBJECT_SIZE(1) + 2*JSON_OBJECT_SIZE(2) + 7*JSON_OBJECT_SIZE(4) + 3*JSON_OBJECT_SIZE(6) + 2*JSON_OBJECT_SIZE(7) + 1130; DynamicJsonDocument doc(capacity); deserializeJson(doc, payload); JsonArray fields = doc["fields"]; JsonObject features_0_attributes = doc["features"][0]["attributes"]; const char* features_0_attributes_Country_Region = features_0_attributes["Country_Region"]; // "Afghanistan" int features_0_attributes_Confirmed = features_0_attributes["Confirmed"]; // 84 int features_0_attributes_Recovered = features_0_attributes["Recovered"]; // 2 int features_0_attributes_Deaths = features_0_attributes["Deaths"]; // 2 Serial.println(features_0_attributes_Country_Region); Serial.println(features_0_attributes_Confirmed); Serial.println(features_0_attributes_Recovered); Serial.println(features_0_attributes_Deaths); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Confirmed); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Deaths); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Recovered); delay(2000); } else { Serial.println("Error on HTTP request"); } https.end(); return; } void Bhutan() { HTTPClient https; String data; https.begin(url3); int httpCode = https.GET(); if (httpCode > 0) { //Check for the returning code String payload = https.getString(); char charBuf[500]; payload.toCharArray(charBuf, 500); //Serial.println(payload); const size_t capacity = JSON_ARRAY_SIZE(4) + JSON_ARRAY_SIZE(7) + 7*JSON_OBJECT_SIZE(1) + 2*JSON_OBJECT_SIZE(2) + 7*JSON_OBJECT_SIZE(4) + 3*JSON_OBJECT_SIZE(6) + 2*JSON_OBJECT_SIZE(7) + 1130; DynamicJsonDocument doc(capacity); deserializeJson(doc, payload); JsonArray fields = doc["fields"]; JsonObject features_0_attributes = doc["features"][0]["attributes"]; const char* features_0_attributes_Country_Region = features_0_attributes["Country_Region"]; // "Afghanistan" int features_0_attributes_Confirmed = features_0_attributes["Confirmed"]; // 84 int features_0_attributes_Recovered = features_0_attributes["Recovered"]; // 2 int features_0_attributes_Deaths = features_0_attributes["Deaths"]; // 2 Serial.println(features_0_attributes_Country_Region); Serial.println(features_0_attributes_Confirmed); Serial.println(features_0_attributes_Recovered); Serial.println(features_0_attributes_Deaths); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Confirmed); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Deaths); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Recovered); delay(2000); } else { Serial.println("Error on HTTP request"); } https.end(); return; } void India() { HTTPClient https; String data; https.begin(url4); int httpCode = https.GET(); if (httpCode > 0) { //Check for the returning code String payload = https.getString(); char charBuf[500]; payload.toCharArray(charBuf, 500); //Serial.println(payload); const size_t capacity = JSON_ARRAY_SIZE(4) + JSON_ARRAY_SIZE(7) + 7*JSON_OBJECT_SIZE(1) + 2*JSON_OBJECT_SIZE(2) + 7*JSON_OBJECT_SIZE(4) + 3*JSON_OBJECT_SIZE(6) + 2*JSON_OBJECT_SIZE(7) + 1130; DynamicJsonDocument doc(capacity); deserializeJson(doc, payload); JsonArray fields = doc["fields"]; JsonObject features_0_attributes = doc["features"][0]["attributes"]; const char* features_0_attributes_Country_Region = features_0_attributes["Country_Region"]; // "Afghanistan" int features_0_attributes_Confirmed = features_0_attributes["Confirmed"]; // 84 int features_0_attributes_Recovered = features_0_attributes["Recovered"]; // 2 int features_0_attributes_Deaths = features_0_attributes["Deaths"]; // 2 Serial.println(features_0_attributes_Country_Region); Serial.println(features_0_attributes_Confirmed); Serial.println(features_0_attributes_Recovered); Serial.println(features_0_attributes_Deaths); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Confirmed); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Deaths); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Recovered); delay(2000); } else { Serial.println("Error on HTTP request"); } https.end(); return; } void Maldives() { HTTPClient https; String data; https.begin(url5); int httpCode = https.GET(); if (httpCode > 0) { //Check for the returning code String payload = https.getString(); char charBuf[500]; payload.toCharArray(charBuf, 500); //Serial.println(payload); const size_t capacity = JSON_ARRAY_SIZE(4) + JSON_ARRAY_SIZE(7) + 7*JSON_OBJECT_SIZE(1) + 2*JSON_OBJECT_SIZE(2) + 7*JSON_OBJECT_SIZE(4) + 3*JSON_OBJECT_SIZE(6) + 2*JSON_OBJECT_SIZE(7) + 1130; DynamicJsonDocument doc(capacity); deserializeJson(doc, payload); JsonArray fields = doc["fields"]; JsonObject features_0_attributes = doc["features"][0]["attributes"]; const char* features_0_attributes_Country_Region = features_0_attributes["Country_Region"]; // "Afghanistan" int features_0_attributes_Confirmed = features_0_attributes["Confirmed"]; // 84 int features_0_attributes_Recovered = features_0_attributes["Recovered"]; // 2 int features_0_attributes_Deaths = features_0_attributes["Deaths"]; // 2 Serial.println(features_0_attributes_Country_Region); Serial.println(features_0_attributes_Confirmed); Serial.println(features_0_attributes_Recovered); Serial.println(features_0_attributes_Deaths); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Confirmed); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Deaths); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Recovered); delay(2000); } else { Serial.println("Error on HTTP request"); } https.end(); return; } void Nepal() { HTTPClient https; String data; https.begin(url6); int httpCode = https.GET(); if (httpCode > 0) { //Check for the returning code String payload = https.getString(); char charBuf[500]; payload.toCharArray(charBuf, 500); //Serial.println(payload); const size_t capacity = JSON_ARRAY_SIZE(4) + JSON_ARRAY_SIZE(7) + 7*JSON_OBJECT_SIZE(1) + 2*JSON_OBJECT_SIZE(2) + 7*JSON_OBJECT_SIZE(4) + 3*JSON_OBJECT_SIZE(6) + 2*JSON_OBJECT_SIZE(7) + 1130; DynamicJsonDocument doc(capacity); deserializeJson(doc, payload); JsonArray fields = doc["fields"]; JsonObject features_0_attributes = doc["features"][0]["attributes"]; const char* features_0_attributes_Country_Region = features_0_attributes["Country_Region"]; // "Afghanistan" int features_0_attributes_Confirmed = features_0_attributes["Confirmed"]; // 84 int features_0_attributes_Recovered = features_0_attributes["Recovered"]; // 2 int features_0_attributes_Deaths = features_0_attributes["Deaths"]; // 2 Serial.println(features_0_attributes_Country_Region); Serial.println(features_0_attributes_Confirmed); Serial.println(features_0_attributes_Recovered); Serial.println(features_0_attributes_Deaths); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Confirmed); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Deaths); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Recovered); delay(2000); } else { Serial.println("Error on HTTP request"); } https.end(); return; } void Pakistan() { HTTPClient https; String data; https.begin(url7); int httpCode = https.GET(); if (httpCode > 0) { //Check for the returning code String payload = https.getString(); char charBuf[500]; payload.toCharArray(charBuf, 500); //Serial.println(payload); const size_t capacity = JSON_ARRAY_SIZE(4) + JSON_ARRAY_SIZE(7) + 7*JSON_OBJECT_SIZE(1) + 2*JSON_OBJECT_SIZE(2) + 7*JSON_OBJECT_SIZE(4) + 3*JSON_OBJECT_SIZE(6) + 2*JSON_OBJECT_SIZE(7) + 1130; DynamicJsonDocument doc(capacity); deserializeJson(doc, payload); JsonArray fields = doc["fields"]; JsonObject features_0_attributes = doc["features"][0]["attributes"]; const char* features_0_attributes_Country_Region = features_0_attributes["Country_Region"]; // "Afghanistan" int features_0_attributes_Confirmed = features_0_attributes["Confirmed"]; // 84 int features_0_attributes_Recovered = features_0_attributes["Recovered"]; // 2 int features_0_attributes_Deaths = features_0_attributes["Deaths"]; // 2 Serial.println(features_0_attributes_Country_Region); Serial.println(features_0_attributes_Confirmed); Serial.println(features_0_attributes_Recovered); Serial.println(features_0_attributes_Deaths); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Confirmed); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Deaths); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Recovered); delay(2000); } else { Serial.println("Error on HTTP request"); } https.end(); return; } void Srilanka() { HTTPClient https; String data; https.begin(url8); int httpCode = https.GET(); if (httpCode > 0) { //Check for the returning code String payload = https.getString(); char charBuf[500]; payload.toCharArray(charBuf, 500); //Serial.println(payload); const size_t capacity = JSON_ARRAY_SIZE(4) + JSON_ARRAY_SIZE(7) + 7*JSON_OBJECT_SIZE(1) + 2*JSON_OBJECT_SIZE(2) + 7*JSON_OBJECT_SIZE(4) + 3*JSON_OBJECT_SIZE(6) + 2*JSON_OBJECT_SIZE(7) + 1130; DynamicJsonDocument doc(capacity); deserializeJson(doc, payload); JsonArray fields = doc["fields"]; JsonObject features_0_attributes = doc["features"][0]["attributes"]; const char* features_0_attributes_Country_Region = features_0_attributes["Country_Region"]; // "Afghanistan" int features_0_attributes_Confirmed = features_0_attributes["Confirmed"]; // 84 int features_0_attributes_Recovered = features_0_attributes["Recovered"]; // 2 int features_0_attributes_Deaths = features_0_attributes["Deaths"]; // 2 Serial.println(features_0_attributes_Country_Region); Serial.println(features_0_attributes_Confirmed); Serial.println(features_0_attributes_Recovered); Serial.println(features_0_attributes_Deaths); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 0, 255); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Case:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Confirmed); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(255, 0, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Death:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Deaths); delay(2000); lcd.clear(); lcd.setCursor(0, 0); lcd.setRGB(0, 255, 0); lcd.print(features_0_attributes_Country_Region); lcd.setCursor(0, 1); lcd.print("Recover:"); lcd.setCursor(8, 1); lcd.print(features_0_attributes_Recovered); delay(2000); } else { Serial.println("Error on HTTP request"); } https.end(); return; } |